from fastapi import APIRouter, Depends, Query
from sqlalchemy.orm import Session

from common.database import get_db
from core.response import resp_200, resp_400
from core.logger import logger


from app.monitor_metrics.handlers.prom_host_info_handler import PromHostInfoHandler
from app.monitor_metrics.handlers.prom_host_group_handler import PromHostGroupHandler
from app.monitor_metrics.handlers.prom_department_handler import PromDepartmentHandler
from app.manage_notice.handlers.manage_notice_user_handler import ManageNoticeUserHandler
from app.manage_notice.handlers.manage_notice_team_handler import ManageNoticeTeamHandler
from app.monitor_metrics.handlers.prom_alarm_metrics_handler import PromAlarmMetricsHandler
from app.monitor_metrics.handlers.prom_alarm_strategy_handler import PromAlarmStrategyHandler
from app.monitor_metrics.handlers.prom_alarm_template_handler import PromAlarmTemplateHandler
from app.monitor_metrics.handlers.prom_alarm_rule_handler import PromAlarmRuleHandler
from app.monitor_metrics.handlers.prom_alarm_group_handler import PromAlarmGroupHandler
from app.monitor_metrics.handlers.prom_alarm_set_handler import PromAlarmSetHandler
from app.monitor_metrics.handlers.prom_alarm_record_handler import PromAlarmRecordHandler
from app.monitor_metrics.handlers.prom_network_probe_handler import PromNetworkProbeHandler
from app.monitor_metrics.handlers.prom_network_group_handler import PromNetworkGroupHandler


from app.monitor_metrics.schemas import *
from common.welab_k8s import init_k8s

router = APIRouter()



#### 主机操作 ####
@router.get('/host/info/', summary="获取主机信息, 根据表字段--模糊匹配", description="统一监控-指标监控")
async def get_prom_host_info_search(field: str = Query("all"), value: str = Query(""), page: int = Query(1, ge=1), per_page: int = Query(10, ge=0),
        db: Session = Depends(get_db)):
    prom_host_info_handler = PromHostInfoHandler()
    status, result = prom_host_info_handler.get_host_info_search(db, page, per_page, field, value)
    if not status:
        message = "get host info search failed"
        logger.error(f"{message} => page:{page} per_page:{per_page} field:{field} value:{value}")
        return resp_400(message)
    return resp_200(result)


@router.get('/host/info/match/', summary="获取主机信息, 根据表字段--完全匹配", description="统一监控-指标监控")
async def get_prom_host_info_match(field: str = Query(..., description="需要查询的字段"), value: str = Query(..., description="字段的值"),
                              page: int = Query(1, ge=1), per_page: int = Query(10, ge=0),
                              db: Session = Depends(get_db)):
    prom_host_info_handler = PromHostInfoHandler()
    status, result = prom_host_info_handler.get_host_info_match(db, page, per_page, field, value)
    if not status:
        message = "get host info match failed"
        logger.error(f"{message} => page:{page} per_page:{per_page} field:{field} value:{value}")
        return resp_400(message)
    return resp_200(result)


@router.post('/host/info/', summary="增加主机信息", description="统一监控-指标监控")
async def post_prom_host_info(data: PostHostInfo, db: Session = Depends(get_db)):
    prom_host_info_handler = PromHostInfoHandler()
    result = prom_host_info_handler.add_host(db, data.dict())
    if not result:
        message = "post host info failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200()


@router.put('/host/info/', summary="修改主机信息", description="统一监控-指标监控")
async def put_prom_host_info(data: PutHostInfo, db: Session = Depends(get_db)):
    prom_host_info_handler = PromHostInfoHandler()
    result = prom_host_info_handler.update_host(db, data.dict())
    if not result:
        message = "put host info failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200()


@router.delete('/host/info/', summary="删除主机信息", description="统一监控-指标监控")
async def delete_prom_host_info(data: DelBaseModel, db: Session = Depends(get_db)):
    prom_host_info_handler = PromHostInfoHandler()
    result = prom_host_info_handler.delete_host(db, data.dict())
    if not result:
        message = "delete host info failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200()



@router.get('/host/template/', summary="获取主机已经绑定的告警模板信息", description="统一监控-指标监控")
async def get_prom_host_template(uuid: int = Query(..., description="需要查询的主机uuid"), db: Session = Depends(get_db)):
    prom_host_info_handler = PromHostInfoHandler()
    status, result = prom_host_info_handler.get_host_template(db, uuid)
    if not status:
        message = "get host template failed"
        logger.error(f"{message} => uuid:{uuid}")
        return resp_400(message)
    return resp_200(result)


@router.put('/host/template/', summary="更新主机自定义的告警模板", description="统一监控-指标监控")
async def put_prom_host_template(data: DelBaseModel, db: Session = Depends(get_db)):
    prom_host_info_handler = PromHostInfoHandler()
    result = prom_host_info_handler.put_host_template(db, data.dict())
    if not result:
        message = "post host info failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200()


@router.get('/host/strategy/', summary="获取主机告警策略", description="统一监控-指标监控")
async def get_prom_host_strategy(uuid: int = Query(..., description="需要查询的主机uuid"), db: Session = Depends(get_db)):
    prom_host_info_handler = PromHostInfoHandler()
    status, result = prom_host_info_handler.get_host_strategy(db, uuid)
    if not status:
        message = "get host strategy failed"
        logger.error(f"{message} => uuid:{uuid}")
        return resp_400(message)
    return resp_200(result)


@router.post('/host/strategy/', summary="增加主机自定义告警策略", description="统一监控-指标监控")
async def post_prom_host_strategy(data: PostHostStrategy, db: Session = Depends(get_db)):
    prom_host_info_handler = PromHostInfoHandler()
    result = prom_host_info_handler.post_host_strategy(db, data.dict())
    if not result:
        message = "post host strategy failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200()


@router.put('/host/strategy/', summary="更新主机自定义告警策略", description="统一监控-指标监控")
async def put_prom_host_strategy(data: PutHostStrategy, db: Session = Depends(get_db)):
    prom_host_info_handler = PromHostInfoHandler()
    result = prom_host_info_handler.put_host_strategy(db, data.dict())
    if not result:
        message = "put host strategy failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200()






#### 主机组操作 ####
@router.get('/host/group/', summary="获取主机组信息, 根据表字段-模糊匹配", description="统一监控-指标监控")
async def get_prom_host_group_info_search(field: str = "all", value: str = "", page: int = Query(1, ge=1), per_page: int = Query(10, ge=0),
        db: Session = Depends(get_db)):
    prom_host_group_handler = PromHostGroupHandler()
    status, result = prom_host_group_handler.get_host_group_search(db, page, per_page, field, value)
    if not status:
        message = "get host group info failed"
        logger.error(f"{message} => page:{page} per_page:{per_page} field:{field} value:{value}")
        return resp_400(message)
    return resp_200(result)


@router.get('/host/group/match/', summary="获取主机组信息, 根据表字段-完全匹配", description="统一监控-指标监控")
async def get_prom_host_group_match(field: str = Query(..., description="需要查询的字段"), value: str = Query(..., description="字段的值"),
                               page: int = Query(1, ge=1), per_page: int = Query(10, ge=0),
                               db: Session = Depends(get_db)):
    prom_host_group_handler = PromHostGroupHandler()
    status, result = prom_host_group_handler.get_host_group_match(db, page, per_page, field, value)
    if not status:
        message = "get host group info match failed"
        logger.error(f"{message} => page:{page} per_page:{per_page} field:{field} value:{value}")
        return resp_400(message)
    return resp_200(result)


@router.get('/host/group/hosts/', summary="获取组内的主机信息, 根据主机组的uuid", description="统一监控-指标监控")
async def get_prom_host_group_hosts(uuid: int = Query(..., description="主机组的uuid"),
                               db: Session = Depends(get_db)):
    prom_host_group_handler = PromHostGroupHandler()
    status, result = prom_host_group_handler.get_host_group_hosts(db, uuid)
    if not status:
        message = "get host group info match failed"
        logger.error(f"{message} => uuid:{uuid}")
        return resp_400(message)
    return resp_200(result)


@router.post('/host/group/', summary="增加主机组信息", description="统一监控-指标监控")
async def post_prom_host_group_info(data: PostHostGroup, db: Session = Depends(get_db)):
    prom_host_group_handler = PromHostGroupHandler()
    result = prom_host_group_handler.add_group(db, data.dict())
    if not result:
        message = "post host group info failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200()


@router.put('/host/group/', summary="修改主机组信息", description="统一监控-指标监控")
async def put_prom_host_group_info(data: PutHostGroup, db: Session = Depends(get_db)):
    prom_host_group_handler = PromHostGroupHandler()
    result = prom_host_group_handler.update_group(db, data.dict())
    if not result:
        message = "put host group info failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200()


@router.delete('/host/group/', summary="删除主机组信息", description="统一监控-指标监控")
async def delete_prom_host_group_info(data: DelBaseModel, db: Session = Depends(get_db)):
    prom_host_group_handler = PromHostGroupHandler()
    result = prom_host_group_handler.delete_group(db, data.dict())
    if not result:
        message = "delete host group info failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200()



@router.get('/host/group/template/', summary="获取主机组绑定的告警模板详细信息", description="统一监控-指标监控")
async def get_prom_host_group_template(uuid: int = Query(..., description="主机组的uuid"),
                                  db: Session = Depends(get_db)):
    prom_host_group_handler = PromHostGroupHandler()
    status, result = prom_host_group_handler.get_host_group_template(db, uuid)
    if not status:
        message = "get host group info template failed"
        logger.error(f"{message} => uuid:{uuid} ")
        return resp_400(message)
    return resp_200(result)


@router.post('/host/group/template/', summary="增加主机组与模板的绑定", description="统一监控-指标监控")
async def post_prom_host_group_bind_template(data: PostDelHostGroupBindTemplate, db: Session = Depends(get_db), k8s:None = Depends(init_k8s)):
    prom_host_group_handler = PromHostGroupHandler()
    result = prom_host_group_handler.bind_template(db, data.dict())
    if not result:
        message = "post host group bind template failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200(result)


@router.delete('/host/group/template/', summary="删除主机组与模板的绑定", description="统一监控-指标监控")
async def delete_prom_host_group_bind_template(data: PostDelHostGroupBindTemplate, db: Session = Depends(get_db), k8s: None = Depends(init_k8s)):
    prom_host_group_handler = PromHostGroupHandler()
    result = prom_host_group_handler.unbound_template(db, data.dict())
    if not result:
        message = "delete host group unbound template failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200(result)



@router.get('/host/group/notice/', summary="获取主机组指定的通知小组详细信息", description="统一监控-指标监控")
async def get_prom_host_group_notice(uuid: int = Query(..., description="主机组的uuid"),
                               db: Session = Depends(get_db)):
    prom_host_group_handler = PromHostGroupHandler()
    status, result = prom_host_group_handler.get_host_group_notice(db, uuid)
    if not status:
        message = "get host group info notice failed"
        logger.error(f"{message} => uuid:{uuid} ")
        return resp_400(message)
    return resp_200(result)


@router.put('/host/group/notice/', summary="更新主机组的负责人", description="统一监控-指标监控")
async def put_prom_host_group_notice(data: PutHostGroupNotice, db: Session = Depends(get_db), k8s:None = Depends(init_k8s)):
    prom_host_group_handler = PromHostGroupHandler()
    result = prom_host_group_handler.put_host_group_notice(db, data.dict())
    if not result:
        message = "put host group notice failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200(result)



@router.post('/host/group/hosts/', summary="增加已注册的主机批量到主机组", description="统一监控-指标监控")
async def post_prom_host_group_add_hosts(data: PostDelHostGroupAddHosts, db: Session = Depends(get_db)):
    prom_host_group_handler = PromHostGroupHandler()
    result = prom_host_group_handler.add_group_hosts(db, data.dict())
    if not result:
        message = "post host group add hosts failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200()


@router.delete('/host/group/hosts/', summary="删除主机组批量的主机", description="统一监控-指标监控")
async def delete_prom_host_group_add_hosts(data: PostDelHostGroupAddHosts, db: Session = Depends(get_db)):
    prom_host_group_handler = PromHostGroupHandler()
    result = prom_host_group_handler.delete_group_hosts(db, data.dict())
    if not result:
        message = "delete host group remove hosts failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200()









#### 部门操作 ####
@router.get('/department/info/', summary="获取部门信息, 根据表字段-模糊匹配", description="统一监控-指标监控")
async def get_prom_department_info_search(field: str = Query("all"), value: str = Query(""), page: int = Query(1, ge=1), per_page: int = Query(10, ge=0),
        db: Session = Depends(get_db)):
    prom_department_handler = PromDepartmentHandler()
    status, result = prom_department_handler.get_department_search(db, page, per_page, field, value)
    if not status:
        message = "get department info search failed"
        logger.error(f"{message} => page:{page} per_page:{per_page} field:{field} value:{value}")
        return resp_400(message)
    return resp_200(result)

#
# @router.get('/department/info/match/', summary="根据表字段-完全匹配, 获取部门信息", description="统一监控-指标监控")
# async def get_department_info_match(field: str = Query(..., description="需要查询的字段"), value: str = Query(..., description="字段的值"),
#                                     page: int = Query(1, ge=1), per_page: int = Query(10, ge=0),
#                                     db: Session = Depends(get_db)):
#     prom_department_info_handler = PromDepartmentHandler()
#     result = prom_department_info_handler.get_department_match(db, page, per_page, field, value)
#     if not result:
#         message = "get department info match failed"
#         logger.error(f"{message} => page:{page} per_page:{per_page} field:{field} value:{value}")
#         return resp_400(message)
#     return resp_200(result)


@router.post('/department/info/', summary="增加部门信息", description="统一监控-指标监控")
async def post_prom_department_info(data: PostDepartmentInfo, db: Session = Depends(get_db)):
    prom_department_info_handler = PromDepartmentHandler()
    result = prom_department_info_handler.add_department(db, data.dict())
    if not result:
        message = "post department info failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200()


@router.put('/department/info/', summary="修改部门信息", description="统一监控-指标监控")
async def put_prom_department_info(data: PutDepartmentInfo, db: Session = Depends(get_db)):
    prom_department_info_handler = PromDepartmentHandler()
    result = prom_department_info_handler.update_department(db, data.dict())
    if not result:
        message = "put department info failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200()


@router.delete('/department/info/', summary="删除部门信息", description="统一监控-指标监控")
async def delete_prom_department_info(data: DelBaseModel, db: Session = Depends(get_db)):
    prom_department_info_handler = PromDepartmentHandler()
    result = prom_department_info_handler.delete_department(db, data.dict())
    if not result:
        message = "delete department info failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200()











#### 告警指标操作 ####
@router.get('/alarm/metrics/', summary="获取告警指标信息, 根据表字段-模糊匹配", description="统一监控-指标监控")
async def get_prom_alarm_metrics_search(field: str = Query("all"), value: str = Query(""), page: int = Query(1, ge=1),per_page: int = Query(10, ge=0),
        db: Session = Depends(get_db)):
    prom_alarm_metrics_handler = PromAlarmMetricsHandler()
    status, result = prom_alarm_metrics_handler.get_alarm_metrics_search(db, page, per_page, field, value)
    if not status:
        message = "get alarm metrics search failed"
        logger.error(f"{message} => page:{page} per_page:{per_page} field:{field} value:{value}")
        return resp_400(message)
    return resp_200(result)

#
# @router.get('/alarm/metrics/match/', summary="根据表字段-完全匹配, 获取告警指标信息", description="统一监控-指标监控")
# async def get_alarm_metrics_match(field: str = Query(..., description="需要查询的字段"), value: str = Query(..., description="字段的值"),
#                                   page: int = Query(1, ge=1),per_page: int = Query(10, ge=0),
#                                   db: Session = Depends(get_db)):
#     prom_alarm_metrics_handler = PromAlarmMetricsHandler()
#     result = prom_alarm_metrics_handler.get_alarm_metrics_match(db, page, per_page, field, value)
#     if not result:
#         message = "get alarm metrics match failed"
#         logger.error(f"{message} => page:{page} per_page:{per_page} field:{field} value:{value}")
#         return resp_400(message)
#     return resp_200(result)


@router.get('/alarm/metrics/classes/', summary="获取告警指标信息, 根据classes表字段", description="统一监控-指标监控")
async def get_prom_alarm_metrics_match(classes: ClassesInfo = Query(..., description="告警指标归类"),
                                  type: AlarmRuleType = Query(..., description="告警指标类型"),
                                  page: int = Query(1, ge=1),per_page: int = Query(10, ge=0),
                                  db: Session = Depends(get_db)):
    prom_alarm_metrics_handler = PromAlarmMetricsHandler()
    status, result = prom_alarm_metrics_handler.get_alarm_metrics_classes(db, page, per_page, classes, type)
    if not status:
        message = "get alarm metrics classes failed"
        logger.error(f"{message} => page:{page} per_page:{per_page} classes:{classes} type:{type}")
        return resp_400(message)
    return resp_200(result)


@router.post('/alarm/metrics/', summary="增加告警指标信息", description="统一监控-指标监控")
async def post_prom_alarm_metrics(data: PostAlarmMetrics, db: Session = Depends(get_db)):
    prom_alarm_metrics_handler = PromAlarmMetricsHandler()
    result = prom_alarm_metrics_handler.add_alarm_metrics(db, data.dict())
    if not result:
        message = "post alarm metrics failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200()


@router.put('/alarm/metrics/', summary="修改告警指标信息", description="统一监控-指标监控")
async def put_prom_alarm_metrics(data: PutAlarmMetrics, db: Session = Depends(get_db)):
    prom_alarm_metrics_handler = PromAlarmMetricsHandler()
    result = prom_alarm_metrics_handler.update_alarm_metrics(db, data.dict())
    if not result:
        message = "put alarm metrics failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200()


@router.delete('/alarm/metrics/', summary="删除告警指标信息", description="统一监控-指标监控")
async def delete_prom_alarm_metrics(data: DelBaseModel, db: Session = Depends(get_db)):
    prom_alarm_metrics_handler = PromAlarmMetricsHandler()
    result = prom_alarm_metrics_handler.delete_alarm_metrics(db, data.dict())
    if not result:
        message = "delete alarm metrics failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200()






#### 告警策略操作 ####
@router.get('/alarm/strategy/', summary="获取告警策略信息, 根据表字段-模糊匹配", description="统一监控-指标监控")
async def get_prom_alarm_strategy_search(field: str = Query("all"), value: str = Query(""), page: int = Query(1, ge=1), per_page: int = Query(10, ge=0),
        db: Session = Depends(get_db)):
    prom_alarm_strategy_handler = PromAlarmStrategyHandler()
    status, result = prom_alarm_strategy_handler.get_alarm_strategy_search(db, page, per_page, field, value)
    if not status:
        message = "get alarm strategy search failed"
        logger.error(f"{message} => page:{page} per_page:{per_page} field:{field} value:{value}")
        return resp_400(message)
    return resp_200(result)

#
# @router.get('/alarm/strategy/match/', summary="根据表字段-完全匹配, 获取告警策略信息", description="统一监控-指标监控")
# async def get_alarm_strategy_match(field: str = Query(..., description="需要查询的字段"), value: str = Query(..., description="字段的值"),
#                                    page: int = Query(1, ge=1), per_page: int = Query(10, ge=0),
#                                    db: Session = Depends(get_db)):
#     prom_alarm_strategy_handler = PromAlarmStrategyHandler()
#     result = prom_alarm_strategy_handler.get_alarm_strategy_match(db, page, per_page, field, value)
#     if not result:
#         message = "get alarm strategy match failed"
#         logger.error(f"{message} => page:{page} per_page:{per_page} field:{field} value:{value}")
#         return resp_400(message)
#     return resp_200(result)


@router.post('/alarm/strategy/', summary="增加告警策略信息", description="统一监控-指标监控")
async def post_prom_alarm_strategy(data: PostAlarmStrategy, db: Session = Depends(get_db)):
    prom_alarm_strategy_handler = PromAlarmStrategyHandler()
    result = prom_alarm_strategy_handler.add_alarm_strategy(db, data.dict())
    if not result:
        message = "post alarm strategy failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200()


@router.put('/alarm/strategy/', summary="修改告警策略信息", description="统一监控-指标监控")
async def put_prom_alarm_strategy(data: PutAlarmStrategy, db: Session = Depends(get_db), k8s: None = Depends(init_k8s)):
    prom_alarm_strategy_handler = PromAlarmStrategyHandler()
    result = prom_alarm_strategy_handler.update_alarm_strategy(db, data.dict())
    if not result:
        message = "put alarm strategy failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200()


@router.delete('/alarm/strategy/', summary="删除告警策略信息", description="统一监控-指标监控")
async def delete_prom_alarm_strategy(data: DelBaseModel, db: Session = Depends(get_db), k8s: None = Depends(init_k8s)):
    prom_alarm_strategy_handler = PromAlarmStrategyHandler()
    result = prom_alarm_strategy_handler.delete_alarm_strategy(db, data.dict())
    if not result:
        message = "delete alarm strategy failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200()






#### 告警模板操作 ####
@router.get('/alarm/template/', summary="获取告警模板信息, 根据表字段-模糊匹配", description="统一监控-指标监控")
async def get_prom_alarm_template_search(field: str = Query("all"), value: str = Query(""), page: int = Query(1, ge=1), per_page: int = Query(10, ge=0),
        db: Session = Depends(get_db)):
    prom_alarm_template_handler = PromAlarmTemplateHandler()
    status, result = prom_alarm_template_handler.get_alarm_template_search(db, page, per_page, field, value)
    if not status:
        message = "get alarm template search failed"
        logger.error(f"{message} => page:{page} per_page:{per_page} field:{field} value:{value}")
        return resp_400(message)
    return resp_200(result)

#
# @router.get('/alarm/template/match/', summary="根据表字段-完全匹配, 获取告警模板信息", description="统一监控-指标监控")
# async def get_alarm_template_match(field: str = Query(..., description="需要查询的字段"), value: str = Query(..., description="字段的值"),
#                                    page: int = Query(1, ge=1), per_page: int = Query(10, ge=0),
#                                    db: Session = Depends(get_db)):
#     prom_alarm_template_handler = PromAlarmTemplateHandler()
#     result = prom_alarm_template_handler.get_alarm_template_match(db, page, per_page, field, value)
#     if not result:
#         message = "get alarm template search failed"
#         logger.error(f"{message} => page:{page} per_page:{per_page} field:{field} value:{value}")
#         return resp_400(message)
#     return resp_200(result)


@router.get('/alarm/template/strategy/', summary="获取告警模板信息, 根据模板uuid", description="统一监控-指标监控")
async def get_prom_alarm_template_match(uuid: int = Query(..., description="模板uuid"),
                                   db: Session = Depends(get_db)):
    prom_alarm_template_handler = PromAlarmTemplateHandler()
    status, result = prom_alarm_template_handler.get_alarm_template_strategy(db, uuid)
    if not status:
        message = "get alarm template strategy failed"
        logger.error(f"{message} => uuid:{uuid}")
        return resp_400(message)
    return resp_200(result)

@router.post('/alarm/template/', summary="增加告警模板信息", description="统一监控-指标监控")
async def post_prom_alarm_template(data: PostAlarmTemplate, db: Session = Depends(get_db)):
    prom_alarm_template_handler = PromAlarmTemplateHandler()
    result = prom_alarm_template_handler.add_alarm_template(db, data.dict())
    if not result:
        message = "post alarm template failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200()


@router.put('/alarm/template/', summary="修改告警模板信息", description="统一监控-指标监控")
async def put_prom_alarm_template(data: PutAlarmTemplate, db: Session = Depends(get_db), k8s: None = Depends(init_k8s)):
    prom_alarm_template_handler = PromAlarmTemplateHandler()
    result, data = prom_alarm_template_handler.update_alarm_template(db, data.dict())
    if not result:
        message = "put alarm template failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200(data)


@router.delete('/alarm/template/', summary="删除告警模板信息", description="统一监控-指标监控")
async def delete_prom_alarm_template(data: DelBaseModel, db: Session = Depends(get_db)):
    prom_alarm_template_handler = PromAlarmTemplateHandler()
    result = prom_alarm_template_handler.delete_alarm_template(db, data.dict())
    if not result:
        message = "delete alarm template failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200()








#### 告警规则操作 ####
@router.get('/alarm/rule/', summary="获取告警规则信息, 根据表字段-模糊匹配", description="统一监控-指标监控")
async def get_prom_alarm_rule_search(field: str = Query("all"), value: str = Query(""), page: int = Query(1, ge=1), per_page: int = Query(10, ge=0),
        db: Session = Depends(get_db)):
    prom_alarm_rule_handler = PromAlarmRuleHandler()
    status, result = prom_alarm_rule_handler.get_alarm_rule_search(db, page, per_page, field, value)
    if not status:
        message = "get alarm rule search failed"
        logger.error(f"{message} => page:{page} per_page:{per_page} field:{field} value:{value}")
        return resp_400(message)
    return resp_200(result)

#
# @router.get('/alarm/rule/match/', summary="根据表字段-完全匹配, 获取告警规则信息", description="统一监控-指标监控")
# async def get_alarm_rule_match(field: str = Query(..., description="需要查询的字段"), value: str = Query(..., description="字段的值"),
#                                page: int = Query(1, ge=1), per_page: int = Query(10, ge=0),
#                                db: Session = Depends(get_db)):
#     prom_alarm_rule_handler = PromAlarmRuleHandler()
#     result = prom_alarm_rule_handler.get_alarm_rule_match(db, page, per_page, field, value)
#     if not result:
#         message = "get alarm rule match failed"
#         logger.error(f"{message} => page:{page} per_page:{per_page} field:{field} value:{value}")
#         return resp_400(message)
#     return resp_200(result)


@router.post('/alarm/rule/', summary="增加告警规则信息", description="统一监控-指标监控")
async def post_prom_alarm_rule(data: PostAlarmRule, db: Session = Depends(get_db)):
    prom_alarm_rule_handler = PromAlarmRuleHandler()
    # 从接口进来的都是自定义规则
    data_info = data.dict()
    data_info["custom"] = 1
    result = prom_alarm_rule_handler.add_alarm_rule(db, data_info)
    if not result:
        message = "post alarm rule failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200()


@router.put('/alarm/rule/', summary="修改告警规则信息", description="统一监控-指标监控")
async def put_prom_alarm_rule(data: PutAlarmRule, db: Session = Depends(get_db)):
    prom_alarm_rule_handler = PromAlarmRuleHandler()
    result = prom_alarm_rule_handler.update_alarm_rule(db, data.dict())
    if not result:
        message = "put alarm rule failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200()


@router.delete('/alarm/rule/', summary="删除告警规则信息", description="统一监控-指标监控")
async def delete_prom_alarm_rule(data: DelBaseModel, db: Session = Depends(get_db)):
    prom_alarm_rule_handler = PromAlarmRuleHandler()
    result = prom_alarm_rule_handler.delete_alarm_rule(db, data.dict())
    if not result:
        message = "delete alarm rule failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200()








#### 告警规则组操作 ####
@router.get('/alarm/group/', summary="获取告警规则组信息, 根据表字段-模糊匹配", description="统一监控-指标监控")
async def get_prom_alarm_group_search(field: str = Query("all"), value: str = Query(""), page: int = Query(1, ge=1), per_page: int = Query(10, ge=0),
        db: Session = Depends(get_db)):
    prom_alarm_group_handler = PromAlarmGroupHandler()
    status, result = prom_alarm_group_handler.get_alarm_group_search(db, page, per_page, field, value)
    if not status:
        message = "get alarm group search failed"
        logger.error(f"{message} => page:{page} per_page:{per_page} field:{field} value:{value}")
        return resp_400(message)
    return resp_200(result)

#
# @router.get('/alarm/group/match/', summary="根据表字段-完全匹配, 获取告警规则组信息", description="统一监控-指标监控")
# async def get_alarm_group_match(field: str = Query(..., description="需要查询的字段"), value: str = Query(..., description="字段的值"),
#                                 page: int = Query(1, ge=1), per_page: int = Query(10, ge=0),
#                                 db: Session = Depends(get_db)):
#     prom_alarm_group_handler = PromAlarmGroupHandler()
#     result = prom_alarm_group_handler.get_alarm_group_match(db, page, per_page, field, value)
#     if not result:
#         message = "get alarm group match failed"
#         logger.error(f"{message} => page:{page} per_page:{per_page} field:{field} value:{value}")
#         return resp_400(message)
#     return resp_200(result)


@router.get('/alarm/group/rule/', summary="获取规则组内的告警规则信息, 根据规则组的uuid", description="统一监控-指标监控")
async def get_prom_alarm_group_rule(uuid: int = Query(..., description="规则组的uuid"),
                                db: Session = Depends(get_db)):
    prom_alarm_group_handler = PromAlarmGroupHandler()
    status, result = prom_alarm_group_handler.get_alarm_group_rule(db, uuid)
    if not status:
        message = "get alarm group rule failed"
        logger.error(f"{message} => uuid:{uuid}")
        return resp_400(message)
    return resp_200(result)


@router.post('/alarm/group/', summary="增加告警规则组信息", description="统一监控-指标监控")
async def post_prom_alarm_group(data: PostAlarmGroup, db: Session = Depends(get_db), k8s: None = Depends(init_k8s)):
    prom_alarm_group_handler = PromAlarmGroupHandler()
    result = prom_alarm_group_handler.add_alarm_group(db, data.dict())
    if not result:
        message = "post alarm group failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)

    return resp_200()


@router.put('/alarm/group/', summary="修改告警规则组信息", description="统一监控-指标监控")
async def put_prom_alarm_group(data: PutAlarmGroup, db: Session = Depends(get_db), k8s: None = Depends(init_k8s)):
    prom_alarm_group_handler = PromAlarmGroupHandler()
    result = prom_alarm_group_handler.update_alarm_group(db, data.dict())
    if not result:
        message = "put alarm group failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200()


@router.delete('/alarm/group/', summary="删除告警规则组信息", description="统一监控-指标监控")
async def delete_prom_alarm_group(data: DelBaseModel, db: Session = Depends(get_db), k8s: None = Depends(init_k8s)):
    prom_alarm_group_handler = PromAlarmGroupHandler()
    result = prom_alarm_group_handler.delete_alarm_group(db, data.dict())
    if not result:
        message = "delete alarm group failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200()








#### 告警规则集操作 ####
@router.get('/alarm/set/', summary="获取告警规则集信息, 根据表字段-模糊匹配", description="统一监控-指标监控")
async def get_prom_alarm_set_search(field: str = Query("all"), value: str = Query(""), page: int = Query(1, ge=1), per_page: int = Query(10, ge=0),
        db: Session = Depends(get_db)):
    prom_alarm_set_handler = PromAlarmSetHandler()
    status, result = prom_alarm_set_handler.get_alarm_set_search(db, page, per_page, field, value)
    if not status:
        message = "get alarm set search failed"
        logger.error(f"{message} => page:{page} per_page:{per_page} field:{field} value:{value}")
        return resp_400(message)
    return resp_200(result)


# @router.get('/alarm/set/match/', summary="根据表字段-完全匹配, 获取告警规则集信息", description="统一监控-指标监控")
# async def get_alarm_set_match(field: str = Query(..., description="需要查询的字段"), value: str = Query(..., description="字段的值"),
#                               page: int = Query(1, ge=1), per_page: int = Query(10, ge=0),
#                               db: Session = Depends(get_db)):
#     prom_alarm_set_handler = PromAlarmSetHandler()
#     result = prom_alarm_set_handler.get_alarm_set_match(db, page, per_page, field, value)
#     if not result:
#         message = "get alarm set match failed"
#         logger.error(f"{message} => page:{page} per_page:{per_page} field:{field} value:{value}")
#         return resp_400(message)
#     return resp_200(result)

@router.get('/alarm/set/metrics', summary="获取告警规则集信息, 根据告警指标", description="统一监控-指标监控")
async def get_prom_alarm_set_alarm_metrics(alarm_metrics_uuid: int, db: Session = Depends(get_db)):
    prom_alarm_set_handler = PromAlarmSetHandler()
    status, result = prom_alarm_set_handler.get_alarm_set_alarm_metrics(db, alarm_metrics_uuid)
    if not status:
        message = "get alarm set alarm_metrics failed"
        logger.error(f"{message} => alarm_metrics_uuid:{alarm_metrics_uuid}")
        return resp_400(message)
    return resp_200(result)


@router.get('/alarm/set/group/', summary="获取相关的规则集信息, 根据规则集的uuid", description="统一监控-指标监控")
async def get_prom_alarm_set_group(uuid: int = Query(..., description="规则集的uuid"),
                              db: Session = Depends(get_db)):
    prom_alarm_set_handler = PromAlarmSetHandler()
    status, result = prom_alarm_set_handler.get_alarm_set_group(db, uuid)
    if not status:
        message = "get alarm set group failed"
        logger.error(f"{message} => uuid:{uuid}")
        return resp_400(message)
    return resp_200(result)


@router.post('/alarm/set/', summary="增加告警规则集信息", description="统一监控-指标监控")
async def post_prom_alarm_set(data: PostAlarmSet, db: Session = Depends(get_db), k8s: None = Depends(init_k8s)):
    prom_alarm_set_handler = PromAlarmSetHandler()
    result = prom_alarm_set_handler.add_alarm_set(db, data.dict())
    if not result:
        message = "post alarm set failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200()


@router.put('/alarm/set/', summary="更新告警规则集信息", description="统一监控-指标监控")
async def put_prom_alarm_set(data: PutAlarmSet, db: Session = Depends(get_db), k8s: None = Depends(init_k8s)):
    prom_alarm_set_handler = PromAlarmSetHandler()
    result = prom_alarm_set_handler.update_alarm_set(db, data.dict())
    if not result:
        message = "put alarm set failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200()


@router.put('/alarm/set/sync/', summary="同步告警规则集信息", description="统一监控-指标监控")
async def put_prom_alarm_set_sync(data: PutAlarmSetSync, db: Session = Depends(get_db), k8s: None = Depends(init_k8s)):
    prom_alarm_set_handler = PromAlarmSetHandler()
    result = prom_alarm_set_handler.sync_alarm_set(db, data.dict())
    if not result:
        message = "sync alarm set failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200()

@router.delete('/alarm/set/', summary="删除告警规则集信息", description="统一监控-指标监控")
async def delete_prom_alarm_set(data: DelBaseModel, db: Session = Depends(get_db), k8s: None = Depends(init_k8s)):
    prom_alarm_set_handler = PromAlarmSetHandler()
    result = prom_alarm_set_handler.delete_alarm_set(db, data.dict())
    if not result:
        message = "delete alarm set failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200()







#### 告警记录操作 ####
@router.get('/alarm/record/', summary="获取告警记录信息, 根据表字段--模糊匹配", description="统一监控-指标监控")
async def get_prom_alarm_record_search(field: str = Query("all"), value: str = Query(""), page: int = Query(1, ge=1), per_page: int = Query(10, ge=0),
        db: Session = Depends(get_db)):
    prom_alarm_record_handler = PromAlarmRecordHandler()
    status, result = prom_alarm_record_handler.get_alarm_record_search(db, page, per_page, field, value)
    if not status:
        message = "get alarm record search failed"
        logger.error(f"{message} => page:{page} per_page:{per_page} field:{field} value:{value}")
        return resp_400(message)
    return resp_200(result)


@router.get('/alarm/record/match', summary="获取告警记录信息, 根据表字段--完全匹配", description="统一监控-指标监控")
async def get_prom_alarm_record_match(field: str = Query(..., description="需要查询的字段"), value: str = Query(..., description="字段的值"),
                                 page: int = Query(1, ge=1), per_page: int = Query(10, ge=0),
                                 db: Session = Depends(get_db)):
    prom_alarm_record_handler = PromAlarmRecordHandler()
    status, result = prom_alarm_record_handler.get_alarm_record_match(db, page, per_page, field, value)
    if not status:
        message = "get alarm record match failed"
        logger.error(f"{message} => page:{page} per_page:{per_page} field:{field} value:{value}")
        return resp_400(message)
    return resp_200(result)



@router.get('/alarm/record/block_global', summary="获取屏蔽全局告警的记录信息", description="统一监控-指标监控")
async def get_prom_alarm_record_block_global(db: Session = Depends(get_db)):
    prom_alarm_record_handler = PromAlarmRecordHandler()
    status, result = prom_alarm_record_handler.get_prom_alarm_record_block_global(db)
    if not status:
        message = "get alarm record: block_global failed"
        logger.error(message)
        return resp_400(message)
    return resp_200(result)



@router.put('/alarm/record/', summary="修改告警记录信息", description="统一监控-指标监控")
async def put_prom_alarm_record(data: PutAlarmRecord, db: Session = Depends(get_db)):
    prom_alarm_record_handler = PromAlarmRecordHandler()
    result = prom_alarm_record_handler.update_alarm_record(db, data.dict())
    if not result:
        message = "put alarm record failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200()


@router.delete('/alarm/record/', summary="删除告警记录信息", description="统一监控-指标监控")
async def delete_prom_alarm_record(data: DelBaseModel, db: Session = Depends(get_db)):
    prom_alarm_record_handler = PromAlarmRecordHandler()
    result = prom_alarm_record_handler.delete_alarm_record(db, data.dict())
    if not result:
        message = "delete alarm record failed"
        logger.error(f"{message} => data:{data.dict()}")
        return resp_400(message)
    return resp_200()




# #### 网络探测任务操作 ####
# @router.get('/network/probe/', summary="获取网络探测任务信息, 根据表字段--模糊匹配", description="统一监控-指标监控")
# async def get_prom_network_probe_search(field: str = Query("all"), value: str = Query(""), page: int = Query(1, ge=1), per_page: int = Query(10, ge=0),
#                                    db: Session = Depends(get_db)):
#     prom_network_probe_handler = PromNetworkProbeHandler()
#     status, result = prom_network_probe_handler.get_network_probe_search(db, page, per_page, field, value)
#     if not status:
#         message = "get network probe search failed"
#         logger.error(f"{message} => page:{page} per_page:{per_page} field:{field} value:{value}")
#         return resp_400(message)
#     return resp_200(result)


# @router.get('/network/probe/match/', summary="获取网络探测任务信息, 根据表字段--完全匹配", description="统一监控-指标监控")
# async def get_prom_network_probe_match(field: str = Query(..., description="需要查询的字段"), value: str = Query(..., description="字段的值"),
#                               page: int = Query(1, ge=1), per_page: int = Query(10, ge=0),
#                               db: Session = Depends(get_db)):
#     prom_network_probe_handler = PromNetworkProbeHandler()
#     status, result = prom_network_probe_handler.get_network_probe_match(db, page, per_page, field, value)
#     if not status:
#         message = "get network probe match failed"
#         logger.error(f"{message} => page:{page} per_page:{per_page} field:{field} value:{value}")
#         return resp_400(message)
#     return resp_200(result)


# @router.post('/network/probe/', summary="增加网络探测任务", description="统一监控-指标监控")
# async def post_prom_network_probe(data: PostNetworkProbe, db: Session = Depends(get_db)):
#     prom_network_probe_handler = PromNetworkProbeHandler()
#     result = prom_network_probe_handler.add_network_probe(db, data.dict())
#     if not result:
#         message = "post network probe failed"
#         logger.error(f"{message} => data:{data.dict()}")
#         return resp_400(message)
#     return resp_200()


# @router.put('/network/probe/', summary="修改网络探测任务", description="统一监控-指标监控")
# async def put_prom_network_probe(data: PutNetworkProbe, db: Session = Depends(get_db)):
#     prom_network_probe_handler = PromNetworkProbeHandler()
#     result = prom_network_probe_handler.update_network_probe(db, data.dict())
#     if not result:
#         message = "put network probe failed"
#         logger.error(f"{message} => data:{data.dict()}")
#         return resp_400(message)
#     return resp_200()


# @router.delete('/network/probe/', summary="删除网络探测任务", description="统一监控-指标监控")
# async def delete_prom_network_probe(data: DelBaseModel, db: Session = Depends(get_db)):
#     prom_network_probe_handler = PromNetworkProbeHandler()
#     result = prom_network_probe_handler.delete_network_probe(db, data.dict())
#     if not result:
#         message = "delete network probe failed"
#         logger.error(f"{message} => data:{data.dict()}")
#         return resp_400(message)
#     return resp_200()






# #### 网络探测任务组操作 ####
# @router.get('/network/group/', summary="获取网络探测组信息, 根据表字段-模糊匹配", description="统一监控-指标监控")
# async def get_prom_network_group_search(field: str = "all", value: str = "", page: int = Query(1, ge=1), per_page: int = Query(10, ge=0),
#                                    db: Session = Depends(get_db)):
#     prom_network_group_handler = PromNetworkGroupHandler()
#     status, result = prom_network_group_handler.get_network_group_search(db, page, per_page, field, value)
#     if not status:
#         message = "get network group info failed"
#         logger.error(f"{message} => page:{page} per_page:{per_page} field:{field} value:{value}")
#         return resp_400(message)
#     return resp_200(result)


# @router.get('/network/group/match/', summary="获取网络探测组信息, 根据表字段-完全匹配", description="统一监控-指标监控")
# async def get_prom_network_group_match(field: str = Query(..., description="需要查询的字段"), value: str = Query(..., description="字段的值"),
#                                page: int = Query(1, ge=1), per_page: int = Query(10, ge=0),
#                                db: Session = Depends(get_db)):
#     prom_network_group_handler = PromNetworkGroupHandler()
#     status, result = prom_network_group_handler.get_network_group_match(db, page, per_page, field, value)
#     if not status:
#         message = "get network group info match failed"
#         logger.error(f"{message} => page:{page} per_page:{per_page} field:{field} value:{value}")
#         return resp_400(message)
#     return resp_200(result)



# @router.post('/network/group/', summary="增加网络探测组", description="统一监控-指标监控")
# async def post_prom_network_group_info(data: PostNetworkGroup, db: Session = Depends(get_db)):
#     prom_network_group_handler = PromNetworkGroupHandler()
#     result = prom_network_group_handler.add_network_group(db, data.dict())
#     if not result:
#         message = "post network group failed"
#         logger.error(f"{message} => data:{data.dict()}")
#         return resp_400(message)
#     return resp_200()


# @router.put('/network/group/', summary="修改网络探测组信息", description="统一监控-指标监控")
# async def put_prom_network_group_info(data: PutNetworkGroup, db: Session = Depends(get_db)):
#     prom_network_group_handler = PromNetworkGroupHandler()
#     result = prom_network_group_handler.update_network_group(db, data.dict())
#     if not result:
#         message = "put network group info failed"
#         logger.error(f"{message} => data:{data.dict()}")
#         return resp_400(message)
#     return resp_200()


# @router.delete('/network/group/', summary="删除网络探测组信息", description="统一监控-指标监控")
# async def delete_prom_network_group_info(data: DelBaseModel, db: Session = Depends(get_db)):
#     prom_network_group_handler = PromNetworkGroupHandler()
#     result = prom_network_group_handler.delete_network_group(db, data.dict())
#     if not result:
#         message = "delete network group info failed"
#         logger.error(f"{message} => data:{data.dict()}")
#         return resp_400(message)
#     return resp_200()



# @router.get('/network/group/template/', summary="获取网络探测组绑定的告警模板详细信息", description="统一监控-指标监控")
# async def get_prom_network_group_template(uuid: int = Query(..., description="网络探测组的uuid"),
#                                   db: Session = Depends(get_db)):
#     prom_network_group_handler = PromNetworkGroupHandler()
#     status, result = prom_network_group_handler.get_network_group_template(db, uuid)
#     if not status:
#         message = "get network group info template failed"
#         logger.error(f"{message} => uuid:{uuid} ")
#         return resp_400(message)
#     return resp_200(result)


# @router.post('/network/group/template/', summary="网络探测组绑定模板", description="统一监控-指标监控")
# async def post_prom_network_group_bind_template(data: PostDelHostNetworkBindTemplate, db: Session = Depends(get_db), k8s:None = Depends(init_k8s)):
#     prom_network_group_handler = PromNetworkGroupHandler()
#     result = prom_network_group_handler.network_group_bind_template(db, data.dict())
#     if not result:
#         message = "post network group bind template failed"
#         logger.error(f"{message} => data:{data.dict()}")
#         return resp_400(message)
#     return resp_200(result)


# @router.delete('/network/group/template/', summary="网络探测组解绑模板", description="统一监控-指标监控")
# async def delete_prom_network_group_bind_template(data: PostDelHostNetworkBindTemplate, db: Session = Depends(get_db), k8s: None = Depends(init_k8s)):
#     prom_network_group_handler = PromNetworkGroupHandler()
#     result = prom_network_group_handler.network_group_unbound_template(db, data.dict())
#     if not result:
#         message = "delete network group unbound template failed"
#         logger.error(f"{message} => data:{data.dict()}")
#         return resp_400(message)
#     return resp_200(result)



# @router.get('/network/group/notice/', summary="获取网络探测组指定的通知小组详细信息", description="统一监控-指标监控")
# async def get_prom_network_group_notice(uuid: int = Query(..., description="网络探测组的uuid"),
#                                    db: Session = Depends(get_db)):
#     prom_network_group_handler = PromNetworkGroupHandler()
#     status, result = prom_network_group_handler.get_network_group_notice(db, uuid)
#     if not status:
#         message = "get network group info notice failed"
#         logger.error(f"{message} => uuid:{uuid} ")
#         return resp_400(message)
#     return resp_200(result)


# @router.put('/network/group/notice/', summary="更新网络探测组的负责人", description="统一监控-指标监控")
# async def put_prom_network_group_notice(data: PutHostGroupNotice, db: Session = Depends(get_db), k8s:None = Depends(init_k8s)):
#     prom_network_group_handler = PromNetworkGroupHandler()
#     result = prom_network_group_handler.put_network_group_notice(db, data.dict())
#     if not result:
#         message = "put network group notice failed"
#         logger.error(f"{message} => data:{data.dict()}")
#         return resp_400(message)
#     return resp_200(result)


# @router.get('/network/group/probes/', summary="根据主机组的uuid, 获取组内的网络探测任务信息", description="统一监控-指标监控")
# async def get_prom_network_group_probes(uuid: int = Query(..., description="网络探测组的uuid"),
#                                    db: Session = Depends(get_db)):
#     prom_network_group_handler = PromNetworkGroupHandler()
#     status, result = prom_network_group_handler.get_network_group_probes(db, uuid)
#     if not status:
#         message = "get network group probes failed"
#         logger.error(f"{message} => uuid:{uuid}")
#         return resp_400(message)
#     return resp_200(result)


# @router.post('/network/group/probes/', summary="网络探测组批量添加已注册的探测任务", description="统一监控-指标监控")
# async def post_prom_network_group_add_hosts(data: PostNetworkGroupAddProbes, db: Session = Depends(get_db)):
#     prom_network_group_handler = PromNetworkGroupHandler()
#     result = prom_network_group_handler.network_group_add_probes(db, data.dict())
#     if not result:
#         message = "post network group add probes failed"
#         logger.error(f"{message} => data:{data.dict()}")
#         return resp_400(message)
#     return resp_200()





